<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>七牛云盘系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-toast-plugin@1.3.2/dist/jquery.toast.min.css">
    <style>
        :root {
            --primary-color: #4F46E5;
            --secondary-color: #7C3AED;
            --success-color: #059669;
            --danger-color: #DC2626;
            --warning-color: #D97706;
            --info-color: #2563EB;
        }
        
        body {
            background-color: #F3F4F6;
            min-height: 100vh;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        }
        
        .app-container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 2rem;
        }
        
        .toolbar {
            background: #fff;
            border-radius: 1rem;
            padding: 1rem;
            margin-bottom: 1.5rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            display: flex;
            align-items: center;
            gap: 1rem;
        }
        
        .search-box {
            flex: 1;
            max-width: 400px;
            position: relative;
        }
        
        .search-input {
            width: 100%;
            padding: 0.75rem 1rem;
            padding-left: 2.5rem;
            border: 1px solid #E5E7EB;
            border-radius: 0.75rem;
            font-size: 0.875rem;
        }
        
        .search-icon {
            position: absolute;
            left: 1rem;
            top: 50%;
            transform: translateY(-50%);
            color: #9CA3AF;
        }
        
        .btn-tool {
            padding: 0.75rem 1rem;
            border-radius: 0.75rem;
            border: 1px solid #E5E7EB;
            background: #fff;
            color: #374151;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            transition: all 0.3s ease;
        }
        
        .btn-tool:hover {
            border-color: var(--primary-color);
            color: var(--primary-color);
        }
        
        .btn-tool.active {
            background: var(--primary-color);
            color: #fff;
            border-color: var(--primary-color);
        }
        
        .file-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 1.5rem;
            padding: 1.5rem;
            background: #fff;
            border-radius: 1rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            min-height: 300px;
            position: relative;
            transition: all 0.3s ease;
        }
        
        .file-grid.drag-over {
            background: #F0F9FF;
            border: 2px dashed var(--primary-color);
        }
        
        .file-grid.drag-over::after {
            content: '释放文件开始上传';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 1.5rem;
            color: var(--primary-color);
            pointer-events: none;
        }
        
        .file-card {
            background: #fff;
            border: 1px solid #E5E7EB;
            border-radius: 0.75rem;
            overflow: hidden;
            transition: all 0.3s ease;
        }
        
        .file-card:hover {
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            transform: translateY(-2px);
        }
        
        .file-preview {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #F9FAFB;
            border-bottom: 1px solid #E5E7EB;
        }
        
        .file-preview i {
            font-size: 2.5rem;
            color: #6B7280;
        }
        
        .file-preview img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .file-info {
            padding: 1rem;
        }
        
        .file-name {
            font-weight: 500;
            color: #111827;
            margin-bottom: 0.5rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .file-meta {
            font-size: 0.75rem;
            color: #6B7280;
        }
        
        .file-actions {
            padding: 0.5rem;
            border-top: 1px solid #E5E7EB;
            display: flex;
            justify-content: flex-end;
            gap: 0.5rem;
            background: #F9FAFB;
        }
        
        .btn-icon {
            width: 2rem;
            height: 2rem;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 0.5rem;
            border: none;
            background: transparent;
            color: #6B7280;
            transition: all 0.2s ease;
        }
        
        .btn-icon:hover {
            background: #E5E7EB;
            color: #374151;
        }
        
        .file-list {
            background: #fff;
            border-radius: 1rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        
        .file-row {
            display: flex;
            align-items: center;
            padding: 1rem 1.5rem;
            border-bottom: 1px solid #E5E7EB;
        }
        
        .file-row:last-child {
            border-bottom: none;
        }
        
        .file-row:hover {
            background: #F9FAFB;
        }
        
        .empty-state {
            text-align: center;
            padding: 4rem 2rem;
        }
        
        .empty-state i {
            font-size: 3rem;
            color: #9CA3AF;
            margin-bottom: 1rem;
        }
        
        .loading-spinner {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(255, 255, 255, 0.9);
            padding: 2rem;
            border-radius: 1rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            display: none;
        }
    </style>
</head>
<body>
    <!-- Toast 容器 -->
    <div id="toastContainer" class="toast-container position-fixed bottom-0 end-0 p-3"></div>
    
    <div class="app-container">
        <!-- 工具栏 -->
        <div class="toolbar">
            <div class="search-box">
                <i class="bi bi-search search-icon"></i>
                <input type="search" class="search-input" placeholder="搜索文件..." id="fileSearchInput">
            </div>
            
            <select class="form-select" style="width: auto;" id="sortDropdown">
                <option value="time-desc">最新上传</option>
                <option value="time-asc">最早上传</option>
                <option value="name-asc">名称 A-Z</option>
                <option value="name-desc">名称 Z-A</option>
                <option value="size-desc">大小 ↓</option>
                <option value="size-asc">大小 ↑</option>
            </select>
            
            <button class="btn-tool" id="viewToggle">
                <i class="bi bi-grid"></i>
                <span>视图</span>
            </button>
            
            <label class="btn-tool" for="fileInput">
                <i class="bi bi-cloud-upload"></i>
                <span>上传</span>
            </label>
            <input type="file" id="fileInput" class="d-none" multiple>
    </div>
    
        <!-- 文件容器 -->
        <div id="fileContainer" class="file-grid">
            <!-- 文件列表将通过JavaScript动态加载 -->
        </div>
    </div>
    
    <!-- 加载动画 -->
    <div class="loading-spinner" id="loadingSpinner">
        <div class="spinner-border text-primary" role="status">
            <span class="visually-hidden">加载中...</span>
        </div>
    </div>
    
    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
    <!-- jQuery -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.4/dist/jquery.min.js"></script>
    <!-- jQuery Toast -->
    <script src="https://cdn.jsdelivr.net/npm/jquery-toast-plugin@1.3.2/dist/jquery.toast.min.js"></script>
    <!-- 项目自定义JS -->
    <script src="/js/utilities.js"></script>
    <script src="/js/ui-utils.js"></script>
    <script src="/js/file-list.js"></script>
    <script src="/js/file-operations.js"></script>
    <script src="/js/index.js"></script>

    <!-- 分享对话框 -->
    <div class="modal fade" id="shareModal" tabindex="-1" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">分享文件</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <p>文件：<span id="shareFileName"></span></p>
                    <div class="mb-3">
                        <label for="shareExpiration" class="form-label">链接有效期（小时）</label>
                        <input type="number" class="form-control" id="shareExpiration" value="24" min="1" max="720">
                    </div>
                    <div id="shareLinkContainer" style="display: none;">
                        <label for="shareLink" class="form-label">分享链接</label>
                        <div class="input-group">
                            <input type="text" class="form-control" id="shareLink" readonly>
                            <button class="btn btn-outline-secondary" type="button" id="copyShareLinkBtn">
                                <i class="bi bi-clipboard"></i>
                            </button>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="generateShareLinkBtn">生成共享链接</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 文件详情对话框 -->
    <div class="modal fade" id="fileDetailsModal" tabindex="-1" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">文件详情</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div class="text-center mb-3" id="filePreviewContainer">
                        <!-- 文件预览将在这里显示 -->
                    </div>
                    <div class="table-responsive">
                        <table class="table">
                            <tbody>
                                <tr>
                                    <th style="width: 120px;">文件名</th>
                                    <td id="fileDetailsName"></td>
                                </tr>
                                <tr>
                                    <th>类型</th>
                                    <td id="fileDetailsMimeType"></td>
                                </tr>
                                <tr>
                                    <th>大小</th>
                                    <td id="fileDetailsSize"></td>
                                </tr>
                                <tr>
                                    <th>上传时间</th>
                                    <td id="fileDetailsTime"></td>
                                </tr>
                                <tr>
                                    <th>存储类型</th>
                                    <td id="fileDetailsStorageType"></td>
                                </tr>
                                <tr>
                                    <th>文件哈希</th>
                                    <td id="fileDetailsEtag"></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary download-from-details-btn">
                        <i class="bi bi-download"></i> 下载
                    </button>
                    <button type="button" class="btn btn-info share-file-btn">
                        <i class="bi bi-share"></i> 分享
                    </button>
                    <button type="button" class="btn btn-danger delete-from-details-btn">
                        <i class="bi bi-trash"></i> 删除
                    </button>
                </div>
            </div>
        </div>
    </div>
</body>
</html> 